package cn.zn.modules.zzsys.cur.entity.dto;

import cn.hutool.core.util.StrUtil;
import cn.zn.framework.common.abs.AbsPage;
import cn.zn.modules.zzsys.cur.entity.TTeacherInfo;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author ZN
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TeacherInfoListDTO extends AbsPage<TTeacherInfo> {
    /**
     * 查询内容
     */
    private String search;

    /**
     * 是否验证电子签章
     */
    private Boolean verSign;

    /**
     * 是否有签章图片
     */
    private Boolean hasSign;

    @Override
    public Wrapper<TTeacherInfo> getWrapper() {
        QueryWrapper<TTeacherInfo> wrapper = new QueryWrapper<>();
        if (StrUtil.isNotEmpty(this.search)) {
            wrapper.and(w -> w
                    .like("ID_NO_", this.search)
                    .or().like("WORK_NO_", this.search)
                    .or().like("NAME_", this.search)
                    .or().like("NAME_PY_", this.search));
        }
        if (this.verSign != null) {
            wrapper.eq("VER_SIGN_", this.verSign);
        }
        if (this.hasSign != null) {
            if (this.hasSign) {
                wrapper.isNotNull("SIGN_IMG_PATH_");
            } else {
                wrapper.isNull("SIGN_IMG_PATH_");
            }
        }
        return wrapper;
    }
}